package com.justnow.offer;


import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

/**
 * @author justnow
 * Created on 2020-08-23
 * Description
 */
public class Solution1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        ListNode head = new ListNode(-1);
        ListNode current = head;

        for (int i = 0; i < n; i++) {
            if (i == k - 1) {
                scanner.nextInt();
                continue;
            }
            ListNode temp = new ListNode(scanner.nextInt());
            current.next = temp;
            current = current.next;
        }
        head = head.next;
        while (head != null) {
            System.out.print(head.val + " ");
            head = head.next;
        }
    }

}

class ListNode {
    int val;
    ListNode next;
    public ListNode (int val) {
        this.val = val;
    }
}